<template>
  <div>
    <bpm-c-form>
    <bpm-c-block
                 :key="0"
                 :ptitle="inputTitle[0]"
                 :preadonly="inputReadonly[0]"
                 :pinputtype="inputType[0]"
                 :pline="inputLine[0]"
                 v-model="selectedGridInfo[gridShowInfo[0]]"
                 @valueChanged="setSelectedGridInfoCellIndex('',0)"
    />
    <bpm-c-block
      :key="1"
      :ptitle="inputTitle[1]"
      :preadonly="inputReadonly[1]"
      :pinputtype="inputType[1]"
      :pline="inputLine[1]"
      v-model="selectedGridInfo[gridShowInfo[1]]"
      @valueChanged="setSelectedGridInfoCellIndex('',1)"
    />
    </bpm-c-form>
    <bpm-c-form>
    <bpm-c-block
      :key="2"
      :ptitle="inputTitle[2]"
      :preadonly="inputReadonly[2]"
      :pinputtype="inputType[2]"
      :pline="inputLine[2]"
      v-model="selectedGridInfo[gridShowInfo[2]]"
      @sltvalueChanged="setSelectedGridInfoCellIndex($event,2)"
    />
    <bpm-c-block
      :key="3"
      :ptitle="inputTitle[3]"
      :preadonly="inputReadonly[3]"
      :pinputtype="inputType[3]"
      :pline="inputLine[3]"
      v-model="selectedGridInfo[gridShowInfo[3]]"
      :validateExp="validateExp[3]"
      @valueChanged="setSelectedGridInfoCellIndex($event,3)"
    />
    </bpm-c-form>
    <bpm-c-form>
    <bpm-c-block
      :key="4"
      :ptitle="inputTitle[4]"
      :preadonly="inputReadonly[4]"
      :pinputtype="inputType[4]"
      :pline="inputLine[4]"
      v-model="selectedGridInfo[gridShowInfo[4]]"
      :validateExp="validateExp[4]"
      @valueChanged="setSelectedGridInfoCellIndex('',4)"
    />
    <bpm-c-block
      :key="5"
      :ptitle="inputTitle[5]"
      :preadonly="inputReadonly[5]"
      :pinputtype="inputType[5]"
      :pline="inputLine[5]"
      v-model="selectedGridInfo[gridShowInfo[5]]"
      :validateExp="validateExp[5]"
      @valueChanged="setSelectedGridInfoCellIndex('',5)"
    />
    </bpm-c-form>
    <!--v-model="selectedGridInfo[gridShowInfo[i]]"-->
  </div>
</template>

<script>
import {mapState, mapActions} from 'vuex'

export default {
  name: 'bpmDFeeChoose',
  props: {
    title: '',
    dialogVisible: {
      type: Number,
      default: -1
    },
    pselectType: {
      type: String,
      default: ''
    },
    validateExp: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    let inputLine = [2, 2, 2, 2, 2, 2]
    let inputType = ['text', 'text', 'sltpostsubject', 'number', 'number', 'number']
    let gridShowInfo = ['costcentername', 'orderName', 'subjectcode', 'transferTaxBx', 'notincludetaxessumBx', 'taxrateBx']
    return {
      selectedGridInfoCellIndex: '',
      inputLine: inputLine,
      inputType: inputType,
      gridShowInfo: gridShowInfo
    }
  },
  computed: {
    ...mapState(['ssc', 'chooseDialogEnum', 'pageType', 'pageTypeEnum', 'lang']),
    inputTitle () {
      return [
        this.getLanguage('label.whBtReimburseRcmDetails.costcentername'),
        this.getLanguage('label.whBtReimburseRcmDetails.order'),
        this.getLanguage('label.whBtReimburseRcmDetails.accoutingsubject'),
        this.getLanguage('label.whBtReimburseRcmDetails.transferTaxBx'),
        this.getLanguage('label.whBtReimburseRcmDetails.notincludetaxessumBx'),
        this.getLanguage('label.whBtReimburseRcmDetails.taxrateBx')
      ]
    },
    selectedGridInfo () {
      return this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseRcmDetail
    },
    inputReadonly () {
      switch (this.pageType) {
        case this.pageTypeEnum.approve:
          return [false, false, false, false, false, false]
        case this.pageTypeEnum.approveFee:
          return [true, true, false, false, false, false]
        case this.pageTypeEnum.view:
        case this.pageTypeEnum.draft:
        default:
          return [true, true, true, true, true, true]
      }
    },
    reimbursecompanycode () {
      return this.ssc.reimburse.whBtReimburse.reimbursecompanycode
    },
    reimbursecostcentercode () {
      return this.ssc.reimburse.whBtReimburse.reimbursecostcentercode
    },
    preInternalorder () {
      return {
        reimbursecompanycode: this.reimbursecompanycode,
        reimbursecostcentercode: this.reimbursecostcentercode
      }
    }
  },
  watch: {
    radioValue (to) {
      console.log('rebrusechoose value changed......', to)
    }
  },
  methods: {
    ...mapActions(['updateDataSscCachePaymentInfo', 'queryBudgetSubject']),
    setSelectedGridInfoCellIndex (v, i) {
      this.selectedGridInfoCellIndex = i
      if (i === 2) { // 核算科目
        console.log('bbbbb->', v)
        let vObj1 = JSON.parse(v)
        vObj1 && this.$store.commit('updateSelectRowSscReimburseWhBtReimburseRcmDetail', {
          name: 'subjectcode',
          value: vObj1.budgetSubjectCode
        })
        vObj1 && this.$store.commit('updateSelectRowSscReimburseWhBtReimburseRcmDetail', {
          name: 'accoutingsubject',
          value: vObj1.budgetSubjectName
        })
      } else if (i === 3) { // 转出税额
        this.transferTaxCertOnBlur()
      } else if (i === 4) { // 不含税金额
        this.noTaxAmountCertOnBlur()
      } else if (i === 5) { // 税额
        this.taxCertOnBlur()
      }
    },
    addClicked () {
    },
    updateClicked () {
    },
    deleteClicked () {
    },
    selectClick (i) {
      console.log(i)
      this.dialogVisible = i
    },
    selDialogClicked (aObj) {
      this.dialogVisible = -1
      console.log('choose', aObj)
    },
    setDialogClose () {
      this.dialogVisible = -1
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
